package com.woniuxy.service.impl;

import com.github.pagehelper.PageInfo;
import com.woniuxy.commons.utils.ResStatus;
import com.woniuxy.commons.utils.ResponseResult;
import com.woniuxy.dao.MedicineOrderDao;
import com.woniuxy.entity.MedicineOrder;
import com.woniuxy.entity.RegisteredOrder;
import com.woniuxy.service.MedicineOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class MedicineOrderServiceImpl implements MedicineOrderService {
    @Resource
    private MedicineOrderDao medicineOrderDao;
    @Override
    public ResponseResult findAll(int currentPage, int pageSize) {
        List<MedicineOrder> list = medicineOrderDao.findAll();
        PageInfo<MedicineOrder> pageInfo = PageInfo.of(list);
        ResponseResult responseResult = new ResponseResult<>();

        responseResult.setData(pageInfo);

        responseResult.setCode(200);

        responseResult.setMsg("查询成功");

        responseResult.setStatus(ResStatus.SUCCESS);

        return responseResult;
    }

    @Override
    public ResponseResult search(MedicineOrder medicineOrder) {
        List<MedicineOrder> list=medicineOrderDao.search(medicineOrder);

        ResponseResult responseResult = new ResponseResult<>();

        responseResult.setCode(200);

        responseResult.setMsg("查询成功");

        responseResult.setStatus(ResStatus.SUCCESS);

        responseResult.setData(list);
        return responseResult;

    }

    @Override
    public ResponseResult findByStatus(int status) {
        List<MedicineOrder> list=medicineOrderDao.findBystatus(status);

        ResponseResult responseResult = new ResponseResult<>();

        responseResult.setCode(200);

        responseResult.setMsg("查询成功");

        responseResult.setStatus(ResStatus.SUCCESS);

        responseResult.setData(list);
        return responseResult;
    }

    @Override
    public ResponseResult findByNo(String no) {
       MedicineOrder medicineOrder=medicineOrderDao.findByNo(no);
        return new ResponseResult(200,"成功",medicineOrder,ResStatus.SUCCESS);
    }

    @Override
    public ResponseResult findIds(int id) {
        int [] arr=medicineOrderDao.findIds(id);
        return new ResponseResult(200,"成功",arr,ResStatus.SUCCESS);
    }


}
